﻿using Admin.ApplicationLib.Entities;
using Admin.CommonLib.Models.Permission;
using AutoMapper;

namespace Admin.WebApi.Mappers
{
    public class PermissionProfile : Profile
    {
        public PermissionProfile()
        {
            CreateMap<PermissionEntity, PermissionInfoResponseDto>()
                .ForMember(desc => desc.Key, opt => opt.MapFrom(src => src.Id))
                .ForMember(desc => desc.PermissionType, opt => opt.MapFrom(src => src.Type));

            CreateMap<PermissionEditRequestDto, PermissionEntity>()
                .ForMember(desc => desc.Uri, opt => { opt.MapFrom(src => src.Url); })
                .ForMember(desc => desc.Type, opt => opt.MapFrom(src => src.PermissionType));
        }
    }
}